<%@page import="com.google.appengine.api.blobstore.BlobKey"%>
<%@page import="com.google.appengine.api.images.ImagesServiceFactory"%>
<%@page import="com.google.appengine.api.images.ImagesService"%>
<%@page import="de.tto.dating.entities.User"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page
	import="com.google.appengine.api.blobstore.BlobstoreServiceFactory"%>
<%@ page import="com.google.appengine.api.blobstore.BlobstoreService"%>
<%@ page import="de.tto.dating.entities.ImageDAO"%>


<%
	BlobstoreService blobstoreService = BlobstoreServiceFactory
			.getBlobstoreService();
	ImagesService imagesService = ImagesServiceFactory
			.getImagesService();
%>


<script type="text/javascript">

function checkSize() {
	var node = document.getElementById('file');
	var imgSize = node.files[0].fileSize;
	if (imgSize > 2000000){
		alert('Dein Foto ist zu gross.\nMaximal erlaubte Größe ist 2 MByte');
 		return false;
	}else{
	return true;
	}
}

</script>



<form action="<%=blobstoreService.createUploadUrl("/upload")%>"
	method="post" enctype="multipart/form-data"
	accept="image/jpeg,image/gif,image/x-png"><input type="file"
	id="file" name="upload_foto"> <input type="submit"
	value="Submit" onClick='return checkSize()'></form>


<%
	User user = (User) session.getAttribute("currentUser");
	for (String imgKey : new ImageDAO().getImages(user)) {
%>

<img
	src="http://localhost:8888/serve?blob-key=<%= imgKey %>" />
<br />

<%
	}
%>









